package com.base.cn.platform.os.service.manage.order.goods;

import com.base.cn.platform.os.entity.op.activity.OpActivity;
import com.base.cn.platform.os.entity.order.order.OrderCondition;
import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.manage.BaseService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 订单接口
 *
 * @author s.li
 * @create 2018-05-10-13:52
 */
@FeignClient(name = BaseService.appName,configuration = FeignAuthConfig.class)
public interface OrderService extends BaseService {
    /**
     * 创建赠送商品订单接口
     *
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/order/createFreeOrder")
    Map<String, Object> createFreeOrder(@RequestParam("userId") BigDecimal userId,
                                        @RequestParam("shopData") String shopData);

    /**
     * 前台生成免费订单
     * @param orderDataFrom 创建订单数据
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/order/createWebFreeOrder")
    Map<String,Object> createWebFreeOrder(@RequestBody Map<String,Object> orderDataFrom);

    /**
     * 通过订单号，查询订单对数
     * @param orderNo 订单号
     * @return  Order 订单对象
     */
    @RequestMapping(contextPath + "/order/findOrderBuyNo")
    Map<String,Object> findOrderBuyNo(@RequestParam("orderNo") String orderNo);

    /**
     * 通过ID，查询订单详情
     *
     * @param orderCondition 查询条件
     * @return Order订单对象
     */
    @RequestMapping(contextPath + "/order/findOrderInfo")
    Map<String, Object> findOrderInfo(@RequestBody OrderCondition orderCondition);

    /**
     * 分页查询订单数据列表
     *
     * @param condition      查询条件
     * @param currentPage    页码
     * @param pageSize       页面显示大小
     * @param setUserData    是否设置用户数据
     * @param setDetailsData 是否设置流水数据
     * @param setShopData    是否设置商品数据
     * @return PageInfo<Order>
     */
    @RequestMapping(contextPath + "/order/findWebOrderPage")
    Map<String, Object> findWebOrderPage(@RequestBody Map<String, Object> condition,
                                         @RequestParam(value = "currentPage", required = false, defaultValue = "1") int currentPage,
                                         @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize,
                                         @RequestParam("setUserData") boolean setUserData,
                                         @RequestParam("setDetailsData") boolean setDetailsData,
                                         @RequestParam("setShopData") boolean setShopData,
                                         @RequestParam("setOrderBook") boolean setOrderBook);

    /**
     * 分页查询订单数据列表
     *
     * @param condition      查询条件
     * @param currentPage    页码
     * @param setUserData    是否设置用户数据
     * @param setDetailsData 是否设置流水数据
     * @param setShopData    是否设置商品数据
     * @return PageInfo<Order>
     */
    @RequestMapping(contextPath + "/order/findOrderPage")
    Map<String, Object> findOrderPage(@RequestBody Map<String, Object> condition,
                                      @RequestParam(value = "currentPage", required = false, defaultValue = "1") int currentPage,
                                      @RequestParam("setUserData") boolean setUserData,
                                      @RequestParam("setDetailsData") boolean setDetailsData,
                                      @RequestParam("setShopData") boolean setShopData,
                                      @RequestParam("setOrderBook") boolean setOrderBook);

    /**
     * 查询订单数据列表(不分页)
     * @param condition 查询条件
     * @param setUserData 是否设置用户数据
     * @param setDetailsData 是否设置流水数据
     * @param setShopData 是否设置商品数据
     * @return List<Order>
     */
    @RequestMapping(contextPath + "/order/findOrderList")
    public List<Map<String, Object>> findOrderList(@RequestBody Map<String, Object> condition,
                                                   @RequestParam("setUserData") boolean setUserData,
                                                   @RequestParam("setDetailsData") boolean setDetailsData,
                                                   @RequestParam("setShopData") boolean setShopData,
                                                   @RequestParam("setOrderBook") boolean setOrderBook);
  /**
     * 修改订单状态
     *
     * @param sysUserId       管理员ID
     * @param orderId         订单ID
     * @param orderStatus     订单状态
     * @param payTime         支付时间
     * @param payType         支付类型
     * @param externalOrderNo 第三方支付流水号
     * @param mailName        物流公司
     * @param mailCode        物流单号
     * @param mailTime        发货时间
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/order/updateOrderStatus")
    Map<String, Object> updateOrderStatus(@RequestParam("sysUserId") BigDecimal sysUserId,
                                          @RequestParam("orderId") BigDecimal orderId,
                                          @RequestParam("orderStatus") String orderStatus,
                                          @RequestParam(value = "payTime", required = false) String payTime,
                                          @RequestParam(value = "payType", required = false) String payType,
                                          @RequestParam(value = "externalOrderNo", required = false) String externalOrderNo,
                                          @RequestParam(value = "mailName", required = false) String mailName,
                                          @RequestParam(value = "mailCode", required = false) String mailCode,
                                          @RequestParam(value = "mailTime", required = false) String mailTime);

    /**
     * 删除订单
     *
     * @param orderIds
     * @param userId
     * @return
     */
    @RequestMapping(contextPath + "/order/deleteOrder")
    Map<String, Object> deleteOrder(@RequestParam("orderIds") String orderIds,
                                    @RequestParam("userId") BigDecimal userId);

    /**
     * 前台验证订单是否能购买
     * @param userId 用户ID
     * @param orderNo 订单号
     * @param orderType 订单类型
     * @param payType 支付类型
     * @param price 充值金额
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/order/checkWebOrderData")
    Map<String,Object> checkWebOrderData(@RequestParam("userId") BigDecimal userId,
                                         @RequestParam("orderNo") String orderNo,
                                         @RequestParam("orderType") String orderType,
                                         @RequestParam("payType") String payType,
                                         @RequestParam(value = "price", required = false, defaultValue = "0") double price);

    /**
     * 导出订单数据
     * @param condition 条件
     * @param pageSize 每个Excel显示的数据量
     * @return
     * @throws Exception
     */
    @RequestMapping(contextPath + "/order/downloadExcelOrdersList")
     ResponseEntity<byte[]> downloadExcelOrdersList(@RequestBody Map<String, Object> condition, @RequestParam("pageSize") int pageSize) throws Exception;


    /**
     * 通过ID，查询订单详情
     *
     * @param orderCondition 查询条件
     * @return Order订单对象
     */
    @RequestMapping(contextPath + "/order/orderInfoActivity")
    Map<String,List> orderInfoActivity(@RequestBody OrderCondition orderCondition);

    //=========================================以下是新的代码，与当前功能无关================

    /**
     * 获取支付订单的商品列表
     * @param createOrderDataFrom 创建订单数据
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/order/getPayOrderShopList")
    Map<String,Object> getPayOrderShopList(@RequestBody Map<String, Object> createOrderDataFrom);

    /**
     * 创建支付订单接口
     * @param orderDataFrom 创建订单数据对象
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/order/createPayOrder")
    Map<String,Object> createPayOrder(@RequestBody Map<String, Object> orderDataFrom);

    /**
     * 取消订单
     * @param orderId
     * @return
     */
    @RequestMapping(contextPath +"/order/cancelOrder")
    Map<String,Object> cancelOrder(@RequestParam("orderId") BigDecimal orderId);

    /**
     * 积分兑换商品
     * @param userId
     * @param shopData
     * @return
     */
    @RequestMapping(contextPath +"/order/exchangeFreeOrder")
     Map<String,Object> exchangeFreeOrder(@RequestParam("userId") BigDecimal userId,
                                                @RequestParam("shopData") String shopData);
}